//
//  Client_RF225_Forklift.swift
//  Wmsmobile
//
//  Created by xuNick on 16/9/30.
//  Copyright © 2016年 www.hd123.com. All rights reserved.
//

import UIKit
fileprivate func < <T : Comparable>(lhs: T?, rhs: T?) -> Bool {
  switch (lhs, rhs) {
  case let (l?, r?):
    return l < r
  case (nil, _?):
    return true
  default:
    return false
  }
}

fileprivate func > <T : Comparable>(lhs: T?, rhs: T?) -> Bool {
  switch (lhs, rhs) {
  case let (l?, r?):
    return l > r
  default:
    return rhs < lhs
  }
}


class Client_CalPalletController: HDFounctionBaseController , HDBarcodeInputCellInputDelegate {
    //MARK: - property
    var dataArray = ["取消托盘"]
    override var firstActiveIndexPath: IndexPath?{
        set{
        }
        get{
            return IndexPath(item: 0, section: 0)  //在这里添加需要进入界面就激活的cell的位置
        }
    }
    //MARK: - delegate  

    func clicKReturn(_ cell: HDBarcodeInputCell) {
        self.getData(["piPalletCode" : getText(0, inSection: 0) ?? "" , "piFlag" : "3" , "piUser" : (userInfo?.userName)! , "piStkin" : ""], bodyMethod: "handlePallet", suffix: "330", success: { (dict) in
            self.showMessage("取消托盘成功", success: true)
            }) { (dict) in
                cell.state = inputViewState.wrong
                self.setText(0, inSection: 0, text: nil)
        }
    }
    //MARK: - private
    override func isEmpty() -> (Bool) { //判断控制器是否为空，必须要实现
        if let cell = cellsDict[String(describing: IndexPath(item: 0, section: 0))] as? HDBarcodeInputCell{
            if cell.codeInputView.textField.text?.characters.count > 0 {
                return false
            }else{
                return true
            }
        }
        return false
    }
    //MARK: - tableviewDatasource
    override func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
       return 1
    }
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if let cell = cellsDict[String(describing: indexPath)] {
            return cell
        }else{
            let cell = HDBarcodeInputCell()
            cell.titleView.text = "货品条码"
            cell.InputDelegate = self
            cellsDict.updateValue(cell, forKey: String(describing: indexPath))
            return cell
        }
    }
    
    //MARK: - tableViewDelegate
    }
